import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  BaseEntity,
  CreateDateColumn,
  OneToMany,
} from 'typeorm';
import { Tetri } from '../../tetris/entities/tetri.entity';

@Entity()
export class UserEntity extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'varchar', name: 'name' })
  name: string;

  @Column({ type: 'varchar', name: 'password' })
  password: string;

  @Column({ type: 'varchar', name: 'userName' })
  userName: string;

  @Column({ type: 'varchar', name: 'avatar' })
  avatar: string;

  @CreateDateColumn({ type: 'timestamp' })
  createTime: Date;

  // 假设User与Teris是一对多关系
  @OneToMany((type) => Tetri, (Tetri) => Tetri.user)
  teris?: Tetri[];
}
